package createpattern.builder;

/**
 * builder模式pojo
 *
 * @author seer
 * @date 2018/2/5 17:25
 */
public class JavaBean {
    private String name;
    private String sex;

    private JavaBean(Builder builder) {
        name = builder.name;
        sex = builder.sex;
    }


    public static final class Builder {
        private String name;
        private String sex;

        public Builder() {
        }

        public Builder name(String val) {
            name = val;
            return this;
        }

        public Builder sex(String val) {
            sex = val;
            return this;
        }

        public JavaBean build() {
            return new JavaBean(this);
        }
    }
}
